from google.appengine.ext import db
from domain import comment
from repository import baserepository

class CommentRepository(baserepository.BaseRepository):

    def getByTopic(self, topic):
        query = db.GqlQuery("SELECT * FROM Comment WHERE enabled=True AND topic = :1 ORDER BY date DESC", topic)
        comments = query.fetch(1000)
        return comments

    def save(self, newcomment):
        return super(CommentRepository, self).save(newcomment, comment.Comment)

    def getByKey(self, commentkey):
        return super(CommentRepository, self).getByKey(commentkey, comment.Comment)

    def delete(self, oldcomment):
        super(CommentRepository, self).delete(oldcomment, comment.Comment)